<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:useBean id="triangle" class="main.java.Triangle" scope="page"/>
<jsp:setProperty name="triangle" property="*"/>
<html>
<head>
    <title>三角形计算结果</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .result-container {
            max-width: 500px;
            margin: 100px auto;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
        }
        .result-title {
            text-align: center;
            margin-bottom: 30px;
            color: #333;
        }
        .result-card {
            background-color: #f8f9fa;
            padding: 20px;
            border-radius: 8px;
            margin-bottom: 20px;
        }
        .error-message {
            color: #dc3545;
            text-align: center;
            margin-bottom: 20px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="result-container">
            <h2 class="result-title">计算结果</h2>
            <%
                if (triangle.isValid()) {
            %>
            <div class="result-card">
                <h4 class="mb-3">三角形的边长：</h4>
                <p>第一条边：<%= triangle.getSide1() %></p>
                <p>第二条边：<%= triangle.getSide2() %></p>
                <p>第三条边：<%= triangle.getSide3() %></p>
            </div>
            <div class="result-card">
                <h4 class="mb-3">计算结果：</h4>
                <p>周长：<%= String.format("%.2f", triangle.getPerimeter()) %></p>
                <p>面积：<%= String.format("%.2f", triangle.getArea()) %></p>
            </div>
            <%
                } else {
            %>
            <div class="error-message">
                <p>输入的三边长度无法构成三角形！</p>
                <p>请确保：</p>
                <ul>
                    <li>所有边长都大于0</li>
                    <li>任意两边之和大于第三边</li>
                </ul>
            </div>
            <%
                }
            %>
            <div class="text-center">
                <a href="inputTriangle.jsp" class="btn btn-primary">返回重新输入</a>
            </div>
        </div>
    </div>
</body>
</html>